import api from '@/api';

/**
 * 商品详情
 */
export const goodsDetailGet = (goodsId: any) => {
  return api.get(`/medinstrument/site/goods/goodsDetail?goodsId=${goodsId}`);
};

/**
 * 店铺商品
 */
export const storeShopsGet = (data: any) => {
  return api.get(`/medinstrument/site/storeIndex?supplierId=${data.supplierId}`, {
    page: data.page,
    limit: data.limit,
  });
};

/**
 * 查看资质
 */
export const qualificationGet = (data: any) => {
  return api.get(`/medinstrument/site/supplierQualification?supplierId=${data}`);
};

/**
 * 购物车接口
 */
export const cartGet = () => {
  return api.get('/medinstrument/site/cart');
};

/**
 * 购物车更新
 */
export const updateCarPost = (data: any) => {
  return api.post(
    `/medinstrument/site/cart/updateAmount?amount=${data.amount || 1}&cartItemId=${data.cartItemId}`,
  );
};

/**
 * 购物车删除单个
 */
export const delCartPost = (data: any) => {
  return api.post(`/medinstrument/site/cart/delCart?cartItemId=${data.cartItemId}`);
};

/**
 * 购物车删除多个
 */
export const batchDelCartPost = (data: any) => {
  return api.post(`/medinstrument/site/cart/batchDelCart?cartItemIds=${data}`);
};

/**
 * 购物车选中
 */
export const updateCheckedPost = (data: any) => {
  return api.post(
    `/medinstrument/site/cart/updateChecked?cartItemIds=${data.cartItemIds.join(',')}&checked=${data.checked ? 'YES' : 'NO'}`,
  );
};

/**
 * 结算页面：购物车选中商品
 */
export const checkedCartGet = () => {
  return api.get('/medinstrument/site/cart/getCheckedCart');
};

/**
 * 添加收货地址
 */
export const addShippingPost = (data: any) => {
  return api.post('/medinstrument/site/customer/addShippingDetail', data);
};

/**
 * 更新收货地址
 */
export const updateShippingPost = (data: any) => {
  return api.post('/medinstrument/site/customer/updateShippingDetail', data);
};

/**
 * 删除收货地址
 */
export const delShippingPost = (data: any) => {
  return api.post(
    `/medinstrument/site/customer/delShippingDetail?customerShippingId=${data.customerShippingId}`,
    {},
  );
};
